let form = layui.form;
form.verify({
    len: [/^\S{6,12}$/, "长度不够"],
    diff: function (val) {
        let oldpwd = $('input[name=oldpwd]').val();
        if (oldpwd === val) {
            return '新密码不能与原密码一样'
        }
    },
    same: function (val) {
        let newpwd = $('input[name=newpwd]').val();
        if (newpwd !== val) {
            return '两次密码不一致'
        }
    }
})
$('form').on('submit', function (e) {
    e.preventDefault();
    let data = $(this).serialize();
    $.ajax({
        type: 'post',
        url: '/my/updatepwd',
        data,
        success: function (res) {
            layer.msg(res.message);
            if (res.status === 0) {
                $('form')[0].reset();
            }
        }
    })
})